package yt.kpool.fragment;


import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.annotation.Nullable;

import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

import java.text.NumberFormat;

import butterknife.BindView;
import butterknife.ButterKnife;
import yt.kpool.R;
import yt.kpool.adapter.HomeSecondAdapter;
import yt.kpool.bean.MinerModelDetailsBean;
import yt.kpool.network.NetHelperNew;
import yt.kpool.util.Util;
import yt.kpool.util.imageUtil.GlideUtil;

@SuppressLint("ValidFragment")
public class HomeSecondBFg extends Fragment {
    private MinerModelDetailsBean minerModelDetailsBean;
    @BindView(R.id.imageview)
    ImageView imageview;
    @BindView(R.id.tv_Name)
    TextView tv_Name;
    private String name;
    @BindView(R.id.tv_Manufacturer)
    TextView tv_Manufacturer;
    @BindView(R.id.tv_ReleaseTime)
    TextView tv_ReleaseTime;
    @BindView(R.id.tv_Hashrate)
    TextView tv_Hashrate;
    @BindView(R.id.tv_HashrateUnit)
    TextView tv_HashrateUnit;
    @BindView(R.id.tv_Power)
    TextView tv_Power;
    @BindView(R.id.tv_Algorithm)
    TextView tv_Algorithm;
    @BindView(R.id.gridview)
    GridView gridview;
    @SuppressLint("ValidFragment")
    public HomeSecondBFg(MinerModelDetailsBean minerModelDetailsBean,String Name)
    {
        super();
        this.minerModelDetailsBean = minerModelDetailsBean;
        name=Name;
    }
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fg_homesecondb, container, false);
        ButterKnife.bind(this, view);
        init();
        return view;
    }

   private void init()
   {

       GlideUtil.loadImages(getContext(), NetHelperNew.URL + minerModelDetailsBean.getData().getImage(), imageview);
       tv_Name.setText(name);
       tv_Manufacturer.setText(minerModelDetailsBean.getData().getManufacturer());
       tv_ReleaseTime.setText(minerModelDetailsBean.getData().getReleaseTime());
//     NumberFormat format=NumberFormat.getNumberInstance();
//     format.setMaximumFractionDigits(20);
//     tv_Hashrate.setText(format.format(minerModelDetailsBean.getData().getHashrate())+"");
       tv_Hashrate.setText(Util.FormatHashrate(minerModelDetailsBean.getData().getHashrate()));
//     tv_HashrateUnit.setText(minerModelDetailsBean.getData().getHashrateUnit());
       tv_Power.setText(minerModelDetailsBean.getData().getPower()+"");
       tv_Algorithm.setText(minerModelDetailsBean.getData().getAlgorithm());
       HomeSecondAdapter homeSecondAdapter=new HomeSecondAdapter(getContext(),minerModelDetailsBean.getData().getCoinList());
       gridview.setAdapter(homeSecondAdapter);
   }

}
